cmake_minimum_required(VERSION 3.8)
project(outside_navigation)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
# Find JsonCpp
find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)

# 包含目录
include_directories(
  include
  ${JSONCPP_INCLUDE_DIRS}
  ${EIGEN3_INCLUDE_DIRS}
)

# 创建库
add_library(outside_navigation_lib
  src/outside_navigator.cpp
)

# ament target dependencies
ament_target_dependencies(outside_navigation_lib
  rclcpp
  std_msgs
  sensor_msgs
)

# 链接库
target_link_libraries(outside_navigation_lib
  ${JSONCPP_LIBRARIES}
)

# 创建可执行文件
add_executable(outside_navigator src/outside_navigator.cpp)

target_link_libraries(outside_navigator
  outside_navigation_lib
)

#install targets
install(TARGETS
  outside_navigator
  EXPORT export_${PROJECT_NAME}
  INCLUDES DESTINATION include
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)

# 安装
install(TARGETS
  outside_navigator
  DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY include/
  DESTINATION include/
)

install(DIRECTORY 
  config
  launch
  DESTINATION share/${PROJECT_NAME}
)

ament_export_include_directories(include)
ament_export_libraries(outside_navigator)
ament_export_dependencies(
  rclcpp
  sensor_msgs
  std_msgs
)


if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()


ament_package()
